package cn.cnsuh.controller.web.servlet;


import cn.cnsuh.service.UserService;
import cn.cnsuh.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Servlet implementation class DelServlet
 */
@WebServlet("/delServlet")
public class DelServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String uid = request.getParameter("uid");
		int id = Integer.parseInt(uid);
		UserService service = new UserServiceImpl();
		
		service.deleteUser(id);
		
		response.sendRedirect(request.getContextPath()+"/findAllServlet");
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
